<!DOCTYPE html>
<!--
# @Time : 2021/9/28 21:50 
# @Author : 常雷
# @File : home.thml
# @Software: PyCharm
-->
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>home页面</title>
    <meta name="viewport" content="width-decice-width, initial-scale=1">
    {% load static %}
    <Link href="{% static 'css/bootstrap.min.css' %}" rel="styLesheet">
    <script src="{% static 'js/jquery.min.js' %}"></script>
    <script src="{% static 'js/bootstrap.min.js' %}"></script>
</head>
<body>
<nav class="navbar navbar-inverse">
    <div class="container-fluid">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
                    data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="#">BBS</a>
        </div>

        <!-- Collect the nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <ul class="nav navbar-nav">
                <li class="active"><a href="/home/">博客 <span class="sr-only">(current)</span></a></li>
                <li><a href="#">文字</a></li>
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true"
                       aria-expanded="false">站内搜索:</a>
{#                    <ul class="dropdown-menu">#}
{#                        <li><a href="#">修改密码</a></li>#}
{#                        <li><a href="/set/avatar/">修改头像</a></li>#}
{#                        <li><a href="/backend/?page=1">后台管理</a></li>#}
{#                        <li role="separator" class="divider"></li>#}
{#                        <li><a href="#">退出登录</a></li>#}
{#                        <li role="separator" class="divider"></li>#}
{#                        <li><a href="#">One more separated link</a></li>#}
{#                    </ul>#}
                </li>
            </ul>
            <form class="navbar-form navbar-left" method="post">
                <div class="form-group">
                    {% csrf_token %}
                    <input type="text" class="form-control" placeholder="尽量不要有错字" name="query_content">
                </div>
                <button type="submit" class="btn btn-default" id="id_query"><span class="glyphicon glyphicon-search"></span>搜索</button>
            </form>
            <ul class="nav navbar-nav navbar-right">
                {% if request.user.is_authenticated %}
                    <li><a href="#">{{ request.user.username }}</a></li>
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true"
                           aria-expanded="false">更多操作<span class="caret"></span></a>
                        <ul class="dropdown-menu">
                            <li><a href="#" data-toggle="modal" data-target="#myModal">修改密码</a></li>
                            <li><a href="/set/avatar/">修改头像</a></li>
                            <li><a href="/backend/">后台管理</a></li>
                            <li role="separator" class="divider"></li>
                            <li><a href="{% url 'logout' %}">退出登录</a></li>
                        </ul>
                    </li>
                {% else %}
                    <li><a href="{% url 'reg' %}}">注册</a></li>
                    <li><a href="{% url 'login' %}">登录</a></li>
                {% endif %}
            </ul>
        </div><!-- /.navbar-collapse -->
    </div><!-- /.container-fluid -->
</nav>
<div class="container-fluid">
    <div class="col-md-2">
        <div class="panel panel-default">
            <div class="panel-heading">
                <h3 class="panel-title">推荐游戏1</h3>
            </div>
            <div class="panel-body">
                <a href="https://www.bilibili.com/video/BV1HL4y1p786">武侠新作-天命奇御2</a>
            </div>
        </div>
        <div class="panel panel-danger">
            <div class="panel-heading">
                <h3 class="panel-title">推荐游戏2</h3>
            </div>
            <div class="panel-body">
                <a href="https://www.bilibili.com/video/BV1rL4y1v7cm">剧情作品-小白兔电商</a>
            </div>
        </div>
        <div class="panel panel-info">
            <div class="panel-heading">
                <h3 class="panel-title">推荐up主</h3>
            </div>
            <div class="panel-body">
                <a href="https://space.bilibili.com/617285">半藏-芒果冰OL</a>
            </div>

            <div class="panel-body">
                <a href="https://space.bilibili.com/1276787">稚嫩的魔法师</a>
            </div>
        </div>
    </div>
    {#        站内文章内容#}
    <div class="col-md-8">
        <ul class="media-list">
            {% for article_obj in article_queryset %}
                <li class="media">
                    <h4 class="media-heading"><a href="/{{ article_obj.blog.userinfo.username }}/article/{{ article_obj.pk }}/">{{ article_obj.title }}</a></h4>
                    <div class="media-left">
                        <a href="/media/{{ article_obj.blog.userinfo.avatar }}">
                            <img class="media-object" src="/media/{{ article_obj.blog.userinfo.avatar }}" width="50px" alt="...">
                        </a>
                    </div>
                    <div class="media-body">
                        {{ article_obj.desc }}
                    </div>
                    <br>
                    <div>
                        <span><a href="/{{ article_obj.blog.userinfo.username }}/">{{ article_obj.blog.userinfo.username }}&nbsp;</a></span>
                        <span>发布于&nbsp;</span>
                        <span>{{ article_obj.create_time|date:'Y-m-d' }}&nbsp;</span>
                        <span><span class="glyphicon glyphicon-comment" aria-hidden="true"></span>评论{{ article_obj.comment_num }}&nbsp;</span>
                        <span><span class="glyphicon glyphicon-thumbs-up"></span>点赞{{ article_obj.up_num }}</span>
                    </div>
                </li>
                <hr>
            {% endfor %}
        </ul>
        <div class="pull-right">
            {{ page_obj.page_html|safe }}
        </div>
    </div>
    <div class="col-md-2">
        <div class="lis">
            <div class="phtop">2021新游排行</div>
            <ul>
                <li class="">
                    <div class="show_a">
                        <i>1</i>
                        <a href="https://www.3dmgame.com/games/ggbh/" target="_blank" class="name">鬼谷八荒</a>
                        <div class="type">rpg</div>
                        <div class="hot">3241666</div>
                    </div>
                    <a href="https://www.3dmgame.com/games/ggbh/" target="_blank" class="img">
                        <img src="https://img.3dmgame.com/uploads/images/thumbkwdfirst/20201112/1605171720_495572.jpg">
                        <div class="text">
                            <i>1</i>
                            <div class="bt">鬼谷八荒</div>
                            <p class="p">热度：<span>3241666</span></p>
                            <p class="p">类型：<span>rpg</span></p>
                            <p class="p">发售：<span>2021-01-27</span></p>
                        </div>
                    </a>
                </li>
                <li>
                    <div class="show_a">
                        <i>2</i>
                        <a href="https://www.3dmgame.com/games/nioh2/" target="_blank" class="name">仁王2</a>
                        <div class="type">arpg</div>
                        <div class="hot">1746745</div>
                    </div>
                    <a href="https://www.3dmgame.com/games/nioh2/" target="_blank" class="img">
                        <img src="https://img.3dmgame.com/uploads/images/thumbkwdfirst/20190822/1566464197_493977.jpg">
                        <div class="text">
                            <i>2</i>
                            <div class="bt">仁王2</div>
                            <p class="p">热度：<span>1746745</span></p>
                            <p class="p">类型：<span>arpg</span></p>
                            <p class="p">发售：<span>2021-02-05</span></p>
                        </div>
                    </a>
                </li>
                <li>
                    <div class="show_a">
                        <i>3</i>
                        <a href="https://www.3dmgame.com/games/pal7/" target="_blank" class="name">仙剑奇侠传7</a>
                        <div class="type">rpg</div>
                        <div class="hot">1721947</div>
                    </div>
                    <a href="https://www.3dmgame.com/games/pal7/" target="_blank" class="img">
                        <img src="https://img.3dmgame.com/uploads/images/thumbkwdfirst/20210113/1610528342_292072.jpg">
                        <div class="text">
                            <i>3</i>
                            <div class="bt">仙剑奇侠传7</div>
                            <p class="p">热度：<span>1721947</span></p>
                            <p class="p">类型：<span>rpg</span></p>
                            <p class="p">发售：<span>2021-10-15</span></p>
                        </div>
                    </a>
                </li>
                <li class="">
                    <div class="show_a">
                        <i>4</i>
                        <a href="https://www.3dmgame.com/games/naraka/" target="_blank" class="name">永劫无间</a>
                        <div class="type">act</div>
                        <div class="hot">1367412</div>
                    </div>
                    <a href="https://www.3dmgame.com/games/naraka/" target="_blank" class="img">
                        <img src="https://img.3dmgame.com/uploads/images/thumbkwdfirst/20200610/1591784619_512079.jpg">
                        <div class="text">
                            <i>4</i>
                            <div class="bt">永劫无间</div>
                            <p class="p">热度：<span>1367412</span></p>
                            <p class="p">类型：<span>act</span></p>
                            <p class="p">发售：<span>2021-08-12</span></p>
                        </div>
                    </a>
                </li>
                <li>
                    <div class="show_a">
                        <i>5</i>
                        <a href="https://www.3dmgame.com/games/tabs/" target="_blank" class="name">全面战争模拟器</a>
                        <div class="type">slg</div>
                        <div class="hot">1358212</div>
                    </div>
                    <a href="https://www.3dmgame.com/games/tabs/" target="_blank" class="img">
                        <img src="https://img.3dmgame.com/uploads/images/thumbkwdfirst/20190403/1554285836_695859.jpg">
                        <div class="text">
                            <i>5</i>
                            <div class="bt">全面战争模拟器</div>
                            <p class="p">热度：<span>1358212</span></p>
                            <p class="p">类型：<span>slg</span></p>
                            <p class="p">发售：<span>2021-04-02</span></p>
                        </div>
                    </a>
                </li>
                <li>
                    <div class="show_a">
                        <i>6</i>
                        <a href="https://www.3dmgame.com/games/residentevil8/" target="_blank" class="name">生化危机8：村庄</a>
                        <div class="type">act</div>
                        <div class="hot">1233495</div>
                    </div>
                    <a href="https://www.3dmgame.com/games/residentevil8/" target="_blank" class="img">
                        <img src="https://img.3dmgame.com/uploads/images/thumbkwdfirst/20200612/1591925453_136956.jpg">
                        <div class="text">
                            <i>6</i>
                            <div class="bt">生化危机8：村庄</div>
                            <p class="p">热度：<span>1233495</span></p>
                            <p class="p">类型：<span>act</span></p>
                            <p class="p">发售：<span>2021-05-07</span></p>
                        </div>
                    </a>
                </li>
                <li>
                    <div class="show_a">
                        <i>7</i>
                        <a href="https://www.3dmgame.com/games/es6/" target="_blank" class="name">上古卷轴6</a>
                        <div class="type">rpg</div>
                        <div class="hot">730954</div>
                    </div>
                    <a href="https://www.3dmgame.com/games/es6/" target="_blank" class="img">
                        <img src="https://img.3dmgame.com/uploads/images/thumbkwdfirst/20180711/1531273655_978490.jpg">
                        <div class="text">
                            <i>7</i>
                            <div class="bt">上古卷轴6</div>
                            <p class="p">热度：<span>730954</span></p>
                            <p class="p">类型：<span>rpg</span></p>
                            <p class="p">发售：<span>未知</span></p>
                        </div>
                    </a>
                </li>
                <li class="on">
                    <div class="show_a">
                        <i>11</i>
                        <a href="https://www.3dmgame.com/games/daysgone/" target="_blank" class="name">往日不再</a>
                        <div class="type">act</div>
                        <div class="hot">620003</div>
                    </div>
                    <a href="https://www.3dmgame.com/games/daysgone/" target="_blank" class="img">
                        <img src="https://img.3dmgame.com/uploads/images/thumbkwdfirst/20210224/1614134316_786692.jpg">
                        <div class="text">
                            <i>11</i>
                            <div class="bt">往日不再</div>
                            <p class="p">热度：<span>620003</span></p>
                            <p class="p">类型：<span>act</span></p>
                            <p class="p">发售：<span>2021-05-19</span></p>
                        </div>
                    </a>
                </li>
                <li>
                    <div class="show_a">
                        <i>12</i>
                        <a href="https://www.3dmgame.com/games/mhrise/" target="_blank" class="name">怪物猎人：崛起</a>
                        <div class="type">act</div>
                        <div class="hot">592761</div>
                    </div>
                    <a href="https://www.3dmgame.com/games/mhrise/" target="_blank" class="img">
                        <img src="https://img.3dmgame.com/uploads/images/thumbkwdfirst/20200918/1600393307_507959.png">
                        <div class="text">
                            <i>12</i>
                            <div class="bt">怪物猎人：崛起</div>
                            <p class="p">热度：<span>592761</span></p>
                            <p class="p">类型：<span>act</span></p>
                            <p class="p">发售：<span>2021-03-26</span></p>
                        </div>
                    </a>
                </li>
                <li>
                    <div class="show_a">
                        <i>13</i>
                        <a href="https://www.3dmgame.com/games/nierrv1/" target="_blank" class="name">尼尔：伪装者ver.1.22474487139...</a>
                        <div class="type">act</div>
                        <div class="hot">582864</div>
                    </div>
                    <a href="https://www.3dmgame.com/games/nierrv1/" target="_blank" class="img">
                        <img src="https://img.3dmgame.com/uploads/images/thumbkwdfirst/20200925/1601003292_242926.jpg">
                        <div class="text">
                            <i>13</i>
                            <div class="bt">尼尔：伪装者ver.1.22474487139...</div>
                            <p class="p">热度：<span>582864</span></p>
                            <p class="p">类型：<span>act</span></p>
                            <p class="p">发售：<span>2021-04-24</span></p>
                        </div>
                    </a>
                </li>
            </ul>
        </div>
    </div>
</div>

<!-- 模态框（Modal） -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
					&times;
				</button>
				<h4 class="modal-title" id="myModalLabel">
					修改密码
				</h4>
			</div>
			<div class="modal-body">
                <div class="form-group">
                    <label for="">用户名</label>
                    <input type="text" disabled value="{{ request.user.username }}"  class="form-control">
                </div>
                <div class="form-group">
                    <label for="">原密码</label>
                    <input type="password" id="id_old_password" class="form-control">
                </div>
                <div class="form-group">
                    <label for="">新密码</label>
                    <input type="password" id="id_new_password" class="form-control">
                </div>
                <div class="form-group">
                    <label for="">确认密码</label>
                    <input type="password" id="id_confirm_password" class="form-control">
                </div>
			</div>
			<div class="modal-footer">
                <span style="color: red" id="id_edit_error"></span>
				<button type="button" class="btn btn-default" data-dismiss="modal">关闭
				</button>
				<button type="button" class="btn btn-primary" id="id_edit">
					提交更改
				</button>
			</div>
		</div><!-- /.modal-content -->
	</div><!-- /.modal -->
</div>

<script>
    $('#id_edit').click(function (){
        $.ajax({
            url:'/set_password/',
            type:'post',
            data:{
                'old_password':$('#id_old_password').val(),
                'new_password':$('#id_new_password').val(),
                'confirm_password':$('#id_confirm_password').val(),
                'csrfmiddlewaretoken':'{{ csrf_token }}'
            },
            success:function (args){
                if (args.code === 1000){
                    window.location.reload()
                }else{
                    $('#id_edit_error').text(args.msg)
                }
            }
        })
    })
</script>
</body>
</html>